package com.desire.homework;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author desire
 */
public class _23_md5加密 {
    public static void main(String[] args) throws NoSuchAlgorithmException {
        String pwd = "littleDesire";

        MessageDigest md5 = MessageDigest.getInstance("md5");
        md5.update(pwd.getBytes());
        StringBuilder stringBuilder = new StringBuilder(32);
        for (byte b : md5.digest()) {
            stringBuilder.append(String.format("%02x", b));
        }
        System.out.println("密码: " + pwd);
        System.out.println("密文: " + stringBuilder);
        System.out.println("长度: " + stringBuilder.toString().length());

    }
}
